package pers.yurwisher.rubick.manager.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.yurwisher.rubick.common.base.BaseController;
import pers.yurwisher.rubick.common.wrapper.PageR;
import pers.yurwisher.rubick.common.wrapper.R;
import pers.yurwisher.rubick.manager.pojo.fo.SystemClientFo;
import pers.yurwisher.rubick.manager.pojo.qo.SystemClientQo;
import pers.yurwisher.rubick.manager.pojo.to.SystemClientTo;
import pers.yurwisher.rubick.manager.pojo.vo.SystemClientVo;
import pers.yurwisher.rubick.manager.service.ISystemClientService;

/**
 * @author yq
 * @date 2021-04-22 15:09:29
 * @description system client
 * @since V1.0.0
 */
@RestController
@RequestMapping("/client")
@RequiredArgsConstructor
public class SystemClientController extends BaseController {
    private final ISystemClientService systemClientService;

    @PostMapping
    public R<String> create(@RequestBody SystemClientFo fo) {
        systemClientService.create(fo);
        return R.ok();
    }

    @PostMapping("{id}")
    public R<String> update(@PathVariable(name = "id") Long id, @RequestBody SystemClientFo fo) {
        systemClientService.update(id, fo);
        return R.ok();
    }

    @GetMapping("{id}")
    public R<SystemClientVo> get(@PathVariable(name = "id") Long id) {
        return R.ok(systemClientService.get(id));
    }

    @PostMapping("/delete/{id}")
    public R<String> delete(@PathVariable(name = "id") Long id) {
        systemClientService.delete(id);
        return R.ok();
    }

    @GetMapping
    public R<PageR<SystemClientTo>> list(@ModelAttribute SystemClientQo qo) {
        return R.ok(systemClientService.list(qo));
    }


}
